<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
        <!-- vue特点：数据是响应式的 -->
        <!-- 响应式：数据一旦改变，界面就会自动跟着变 -->
        <button v-on:click="msg = '你坏'" >修改msg</button>
        <!-- 当按钮被点击，就会调用fn1函数 -->
        <button v-on:click="fn1">修改msg并弹出提示</button>
        <button v-on:click="fn2('萨瓦迪卡')">点击调用函数并传参</button>
        <hr>
        <button @click="msg = '你坏'" >修改msg</button>
        <button @click="fn1">修改msg并弹出提示</button>
        <button @click="fn2('萨瓦迪卡')">点击调用函数并传参</button>

        <p>{{ msg }}</p>
    </div>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: '#app',
        data () {
          return {
            msg: '你好'
          }
        },
        methods: {
            fn1 () {
                // 在js部分访问vue的数据，前面要加this
                this.msg = '你好坏'
                console.log('改完了')
            },

            fn2 (str) {
                this.msg = str
            }
        }
      })
    </script>
  </body>
</html>
